package com.ruiyin.controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.SimpleFormatter;

public class BaseController {
    private static String MSG = "msg";
    private static String CODE = "code";
    private static String DATA = "data";
    private static String FAILED = "1001";
    private static Integer SUCCESS = 200;
    static int CODES = -1;
    static int CODE1 = 0;
    static int CODE2 = 1;
    static int CODE3 = 2;
    static int CODE4 = 3;
    static int CODE5 = 4;
    static int FAIL_CODE = 1001;

    public Map<String,Object> sendSuccess(String msg){
        Map<String,Object>content = new HashMap<>();
        content.put(CODE,SUCCESS);
        content.put(MSG,msg);
        return content;
    }
    public Map<String,Object> sendSuccess(int code,String msg){
        Map<String,Object>content = new HashMap<>();
        content.put(CODE,code);
        content.put(MSG,msg);
        return content;
    }
    public Map<String,Object> sendSuccess(int code,String msg,Object data){
        Map<String,Object>content = new HashMap<>();
        content.put(CODE,code);
        content.put(MSG,msg);
        content.put(DATA,data);
        return content;
    }
    public Map<String,Object>sendFailed(String msg){
        Map<String,Object>content = new HashMap<>();
        content.put(CODE,FAILED);
        content.put(MSG,msg);
        return content;
    }
    public Map<String,Object>sendFailed(int code,String msg){
        Map<String,Object>content = new HashMap<>();
        content.put(CODE,code);
        content.put(MSG,msg);
        return content;
    }
}
